package com.yanqu.road.server.manager.activity.shuihuyezipai;

import com.yanqu.road.entity.log.LogShuiHuYeZiCardPVPBattlerRoundRecord;
import com.yanqu.road.entity.log.LogShuiHuYeZiCardPVPMatchRecord;
import com.yanqu.road.logic.bussiness.log.LogBussiness;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author cwq
 * @Data 2022/1/5 15:54
 */
public class ShuiHuYeZiCardActivityLogMgr {

    private static List<LogShuiHuYeZiCardPVPBattlerRoundRecord> logShuiHuYeZiCardPVPBattlerRoundRecordList = new ArrayList<>();
    private static List<LogShuiHuYeZiCardPVPMatchRecord> logShuiHuYeZiCardPVPMatchRecordList = new ArrayList<>();

    public static void addLogShuiHuYeZiCardPVPBattlerRoundRecord(LogShuiHuYeZiCardPVPBattlerRoundRecord log) {
        synchronized (logShuiHuYeZiCardPVPBattlerRoundRecordList) {
            logShuiHuYeZiCardPVPBattlerRoundRecordList.add(log);
        }
    }

    public static void addLogShuiHuYeZiCardPVPMatchRecord(LogShuiHuYeZiCardPVPMatchRecord log) {
        synchronized (logShuiHuYeZiCardPVPMatchRecordList) {
            logShuiHuYeZiCardPVPMatchRecordList.add(log);
        }
    }

    public static void saveLogShuiHuYeZiCard(){
        if (!CollectionUtils.isEmpty(logShuiHuYeZiCardPVPBattlerRoundRecordList)) {
            List<LogShuiHuYeZiCardPVPBattlerRoundRecord> list;
            synchronized (logShuiHuYeZiCardPVPBattlerRoundRecordList) {
                list = new ArrayList<>(logShuiHuYeZiCardPVPBattlerRoundRecordList);
                logShuiHuYeZiCardPVPBattlerRoundRecordList.clear();
            }
            LogBussiness.addLogShuiHuYeZiCardPVPBattlerRoundRecordList(list);
        }
        if (!CollectionUtils.isEmpty(logShuiHuYeZiCardPVPMatchRecordList)) {
            List<LogShuiHuYeZiCardPVPMatchRecord> list;
            synchronized (logShuiHuYeZiCardPVPMatchRecordList) {
                list = new ArrayList<>(logShuiHuYeZiCardPVPMatchRecordList);
                logShuiHuYeZiCardPVPMatchRecordList.clear();
            }
            LogBussiness.addLogShuiHuYeZiCardPVPMatchRecordList(list);
        }
    }


}
